package com.fenghongzhang.day003;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Main4Activity extends AppCompatActivity {

    private EditText editText;
    private Button button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main4);
        //1,先到,2在操作
        button = findViewById(R.id.btn);
        editText = findViewById(R.id.edit);

        //1,输入框
        //2,btn
        //点btn  弹出 输入框中的值.

        //匿名内部类实现点击事件
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //1,取到输入框的值.
                //2.toast取到的值
                String string = editText.getText().toString();
                Toast.makeText(Main4Activity.this, string, Toast.LENGTH_SHORT).show();
            }
        });

    }
}
